package leetcode.剑指offer.剑指II;

import org.junit.Test;

import java.util.*;

/**
 * @author ：zsy
 * @date ：Created 2022/3/19 14:32
 * @description：https://leetcode-cn.com/problems/GzCJIP/
 */
public class 剑指_II_088_爬楼梯的最少成本 {
    @Test
    public void test() {
        Solution solution = new Solution();
        System.out.println(solution.minCostClimbingStairs(new int[]{1, 100, 1, 1, 1, 100, 1, 1, 100, 1}));
    }

    class Solution {
        public int minCostClimbingStairs(int[] cost) {
            int n = cost.length;
            int[] dp = new int[n + 1];
            for (int i = 2; i <= n; i++) {
                dp[i] = Math.min(dp[i - 1] + cost[i - 1], dp[i - 2]  + cost[i - 2]);
            }
            return dp[n];
        }
    }

}
